<?php
namespace Mob\Model;
use Think\Model\RelationModel;
class UserEntrustModel extends  RelationModel 
{
    
    protected $_auto = array (
        array('createdate','date',1,'function',array('Y-m-d H:i:s')),
    );
    
    
	protected $_link = array(
        	    'DomainType'=>array(
        	        'mapping_type'=> self::BELONGS_TO,
        	        'mapping_name'=> 'domainType',
        	        'class_name'=> 'DomainType',
        	        'foreign_key'=>'domain_typeid'
        	    )
    );
    
    /**
     * 插入用户域名委托买卖记录
     * @param unknown $arry
     * @return number|unknown
     */
    public function inst($arry)
    {
        foreach ($arry as $key => $value){
            $data[$key] = $value;
        };
        $result["status"]=0;
        if (!$this->create($data)){
            $result["mess"]=$this->getError();
        }else{
            $result = $this->add(); // 写入数据到数据库
            if($result){
                $result["status"]=1;
                $result["mess"]=$result;
            }
        };
        return $result;
    }
    
    /**
     * 查询用户域名委托买卖记录
     * @param  $arry
     * @return 
     */
	public function getList($arry)
	{  
	    foreach ($arry as $key => $value){
	        $con[$key]=$value;
	    };
        return $this->relation(true)->where($con)->order('id desc')->select();
	}
	
	/**
	 * 查询用户域名委托买卖记录
	 * @param unknown $arry
	 * @return mixed|boolean|string|NULL|unknown|object
	 */
	public function getCount($arry)
	{
	    foreach ($arry as $key => $value){
	        $con[$key]=$value;
	    };
	    return $this->where($con)->count();
	}
}
?>